import pygame, random

class Gkeeper(pygame.sprite.Sprite):
	"""The class for the goalkeeper sprite and logic"""
	
	def __init__(self):
		pygame.sprite.Sprite.__init__(self)
		
		#images for centre pos, left pos, right pos respectively; default is centre
		self.imagec = pygame.image.load("data/img/keeper_centre.png").convert_alpha()
		self.imagel = pygame.image.load("data/img/keeper_left.png").convert_alpha()
		self.imager = pygame.image.load("data/img/keeper_right.png").convert_alpha()
		self.image = self.imagec
		self.rect = self.image.get_rect()
		
		self.rect.x = 350
		self.rect.y = 190
		
	def diveleft(self):
		self.image = self.imagel
		self.rect = self.image.get_rect()
		self.rect.x = 150
		self.rect.y = 190
		
	def diveright(self):
		self.image = self.imager
		self.rect = self.image.get_rect()
		self.rect.x = 480
		self.rect.y = 190
		
	def diver(self, dir):
		#rand = random.randint(1,3)
		
		if dir == 1:
			self.diveleft()
		elif dir == 2:
			self.diveright()
		else:
			return
		
	def reset(self):
		self.image = self.imagec
		self.rect = self.image.get_rect()
		self.rect.x = 350
		self.rect.y = 190
	
